package com.roadjava.rbac.service.impl;

import com.roadjava.rbac.bean.entity.SuggestionDO;
import com.roadjava.rbac.mapper.SuggestionMapper;
import com.roadjava.rbac.service.SuggestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SuggestionServiceImpl implements SuggestionService {

    @Autowired
    private SuggestionMapper suggestionMapper;

    @Override
    public void addSuggestion(SuggestionDO suggestion) {
        suggestionMapper.addSuggestion(suggestion); // 直接使用Mapper添加建议
    }

    @Override
    public void updateSuggestion(SuggestionDO suggestion) {
        suggestionMapper.updateSuggestion(suggestion.getSuggestionid(), suggestion.getResourceid(), suggestion.getContent()); // 直接使用Mapper更新建议
    }

    @Override
    public boolean deleteSuggestion(Integer suggestionId) {
        suggestionMapper.deleteSuggestion(suggestionId); // 直接使用Mapper删除建议
        return false;
    }

    @Override
    public SuggestionDO getSuggestionById(Integer suggestionId) {
        return suggestionMapper.getSuggestionById(suggestionId); // 直接使用Mapper根据ID获取建议
    }

    @Override
    public List<SuggestionDO> getSuggestionsByResourceId(Integer resourceId) {
        return suggestionMapper.getSuggestionsByResourceId(resourceId); // 直接使用Mapper根据资源ID获取建议列表
    }

    @Override
    public List<SuggestionDO> getSuggestionsByUserId(Long userId) {
        return suggestionMapper.getSuggestionsByUserId(userId); // 直接使用Mapper根据用户ID获取建议列表
    }
}
